/**
 * 
 */
package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.BusinesscategoryDAO;
import com.chanyachting.emall.domain.Businesscategory;
import com.chanyachting.emall.domain.Productcategory;
import com.chanyachting.emall.service.BusinesscategoryService;

/**
 * @author robert
 *
 */
public class BusinesscategoryServiceImpl implements BusinesscategoryService {
	
	private BusinesscategoryDAO bcDao;

	/**
	 * 
	 */
	public BusinesscategoryServiceImpl() {
		
		bcDao=new BusinesscategoryDAO();
	}
	
	public BusinesscategoryServiceImpl(BusinesscategoryDAO bcdao) {
		this.bcDao = bcdao;
	}
	

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#addBusinesscategory(com.chanyachting.emall.domain.Businesscategory)
	 */
	public boolean addBusinesscategory(Businesscategory bc) {
		
		this.bcDao.save(bc);
		
		return true;
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#delBusinesscategory(com.chanyachting.emall.domain.Businesscategory)
	 */
	public boolean delBusinesscategory(Businesscategory bc) {
		
		this.bcDao.delete(bc);
		
		return true;
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#getAllBusinesscategory()
	 */
	public List<Businesscategory> getAllBusinesscategory() {
		
		return this.bcDao.find("from Businesscategory order by pri");
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#getOneBusinesscategory(com.chanyachting.emall.domain.Businesscategory)
	 */
	public Businesscategory getOneBusinesscategory(Businesscategory bc) {
		
		return (Businesscategory) this.bcDao.load(Businesscategory.class, bc.getId());
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#getProductcategoryByBusinesscategory(com.chanyachting.emall.domain.Businesscategory)
	 */
	public List<Productcategory> getProductcategoryByBusinesscategory(
			Businesscategory bc) {
		
		return this.bcDao.getProductcategoryByBusinesscategory(bc);
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#updateBusinesscategory(com.chanyachting.emall.domain.Businesscategory)
	 */
	public boolean updateBusinesscategory(Businesscategory bc) {
		
		return this.bcDao.updateBusinesscategory(bc);
	
	}

	/* (non-Javadoc)
	 * @see com.chanyachting.emall.service.BusinesscategoryService#updateBusinesscategoryPri(com.chanyachting.emall.domain.Businesscategory)
	 */
	public boolean updateBusinesscategoryPri(Businesscategory bc) {
		
		return this.bcDao.updateBusinesscategoryPri(bc);
	}

	public Businesscategory getBusinesscategoryById(String id) {
		
		return this.bcDao.getBusinesscategoryById(id);
	}

}
